package com.jxau.controller;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.util.JSONPObject;
import com.jxau.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
public class UserController {
    @RequestMapping("/login")
    public void login(User user, HttpServletResponse res) throws IOException {
        ObjectMapper objectMapper=new ObjectMapper();
        System.out.println("username:"+user.getUsername());
        System.out.println("password:"+user.getPassword());
        System.out.println("----------------------");
        User user1=new User("zgx","123");
        String s = objectMapper.writeValueAsString(user1);
        System.out.println(s);
        res.getWriter().print(s);
    }
    @PostMapping("/test")
    public void test(){
        System.out.println("test");
    }
}
